package chatNI;




import java.io.*;
import java.net.*;


/* 
 * @author Yahya-Albaba
*/

public class ThreadSendMsg extends Thread {

	/**
	 * @param  msg consists of the message that we want to send 
	 * @param  addr is the address of the user to whom we intent to send the message
	 * @param socket It consists of the socket used to send the message 
	 * @param  port is the port for this application
	*/
	
	private byte[] msg;
	private InetAddress addr;
	private DatagramSocket socket;
	private int port;
	public ThreadSendMsg(byte[] msg, InetAddress addr_dest, int port ){
		this.msg=msg;
		this.addr=addr_dest;
		this.port=port;
		}
	
	public void run(){
		DatagramSocket sendingSocket;
		try{
			DatagramPacket packet=new DatagramPacket(msg, msg.length, addr, port);
			sendingSocket=new DatagramSocket();
			sendingSocket.send(packet);
		}catch(IOException e){
			e.printStackTrace();
		}
	}
}